package ve.ejb.metadata;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import ve.ejb.entity.Map;
import ve.ejb.entity.ScoreCard;

/**
 *
 * @author memozac
 */
@Entity
public class Settings implements Serializable {
    private static final long serialVersionUID = 1L;

    public enum Type{SCORECARD,COMPARATOR};

    public enum Command{SUM,AVG,MAX,MIN,MODE,MEDIAN};

    public enum Temporality{LAST,X_MONTHLY,X_YEARLY};

    public enum Frecuency{Y_MONTHLY,Y_YEARLY};

    public enum Polarity{HIGH,LOW,SPECIAL,ZERO_TREND,ZERO_TREND_SPECIAL};

    public enum OperationData{CONSOLIDATE_SUM, CONSOLIDATE_AVG, CALCULATE, NORMAL};

    @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long idSettings;

    @OneToOne private ScoreCard scoreCard;

    @OneToOne private Unit unit;

    @ManyToMany(targetEntity=Map.class) @JoinTable(name="MapSettings", joinColumns=@JoinColumn(name="idSettings"),
    inverseJoinColumns=@JoinColumn(name="idMap")) private Collection<Map> maps;
    
    @ManyToMany(targetEntity=ColorimetryStandard.class) @JoinTable(name="ColorimetryStandardSettings", joinColumns=@JoinColumn(name="idSettings"),
    inverseJoinColumns=@JoinColumn(name="idColorimetryStandard")) private Collection<ColorimetryStandard> colorimetryStandard;

    @Enumerated private Type type;

    @Enumerated private Command command;

    @Enumerated private Temporality temporality;

    @Enumerated private Frecuency frecuency;

    @Enumerated private Polarity polarity;

    @Enumerated private OperationData operationData;

    @Column(columnDefinition="text") private String mathOperation;

    @Column(columnDefinition="text") private String zeroTrendValue;//Used by specialOperation

    @Temporal(value = TemporalType.TIMESTAMP) private Date registerDate;

    private Long x;
    
    private Long y;

    private Long roundDecimal;

    public Date getRegisterDate() {
        return registerDate;
    }

    public void setRegisterDate(Date registerDate) {
        this.registerDate = registerDate;
    }

    public Long getRoundDecimal() {
        return roundDecimal;
    }

    public void setRoundDecimal(Long roundDecimal) {
        this.roundDecimal = roundDecimal;
    }
    
    public String getZeroTrendValue() {
        return zeroTrendValue;
    }

    public void setZeroTrendValue(String zeroTrendValue) {
        this.zeroTrendValue = zeroTrendValue;
    }

    public Command getCommand() {
        return command;
    }

    public void setCommand(Command command) {
        this.command = command;
    }

    public Frecuency getFrecuency() {
        return frecuency;
    }

    public void setFrecuency(Frecuency frecuency) {
        this.frecuency = frecuency;
    }

    public String getMathOperation() {
        return mathOperation;
    }

    public void setMathOperation(String mathOperation) {
        this.mathOperation = mathOperation;
    }

    public OperationData getOperationData() {
        return operationData;
    }

    public void setOperationData(OperationData operationData) {
        this.operationData = operationData;
    }

    public Polarity getPolarity() {
        return polarity;
    }

    public void setPolarity(Polarity polarity) {
        this.polarity = polarity;
    }

    public Temporality getTemporality() {
        return temporality;
    }

    public void setTemporality(Temporality temporality) {
        this.temporality = temporality;
    }

    public Type getType() {
        return type;
    }

    public void setType(Type type) {
        this.type = type;
    }

    public Long getX() {
        return x;
    }

    public void setX(Long x) {
        this.x = x;
    }

    public Long getY() {
        return y;
    }

    public void setY(Long y) {
        this.y = y;
    }

    public Collection<ColorimetryStandard> getColorimetryStandard() {
        return colorimetryStandard;
    }

    public void setColorimetryStandard(Collection<ColorimetryStandard> colorimetryStandard) {
        this.colorimetryStandard = colorimetryStandard;
    }

    public Long getIdSettings() {
        return idSettings;
    }

    public void setIdSettings(Long idSettings) {
        this.idSettings = idSettings;
    }

    public Collection<Map> getMaps() {
        return maps;
    }

    public void setMaps(Collection<Map> maps) {
        this.maps = maps;
    }

    public ScoreCard getScoreCard() {
        return scoreCard;
    }

    public void setScoreCard(ScoreCard scoreCard) {
        this.scoreCard = scoreCard;
    }

    public Unit getUnit() {
        return unit;
    }

    public void setUnit(Unit unit) {
        this.unit = unit;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idSettings != null ? idSettings.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof Settings)) {
            return false;
        }
        Settings other = (Settings) object;
        if ((this.idSettings == null && other.idSettings != null) || (this.idSettings != null && !this.idSettings.equals(other.idSettings))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ve.ejb.entity.Settings[id=" + idSettings + "]";
    }

}//ends of class
